package be.ehb.werkstuk.swing;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import be.ehb.werkstuk.model.Song;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Info extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private JLabel lblTitel;
	private JLabel lblArtiest;
	private JLabel lblGenre;
	private JLabel lblBpm;
	private JTextField txtTitel;
	private JTextField txtArtiest;
	private JTextField txtGenre;
	private JTextField txtBpm;

	public void setWeerTeGevenSong(Song weerTeGevenSong){
		this.txtTitel.setText(weerTeGevenSong.getTitel());
		this.txtArtiest.setText(weerTeGevenSong.getArtiest());
		this.txtGenre.setText(weerTeGevenSong.getGenre());
		this.txtBpm.setText(Integer.toString(weerTeGevenSong.getBpm()));
	}
	
	/**
	 * Launch the application.
	 */
	
	public static void main(String[] args) {
		try {
			Info dialog = new Info();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public Info() {
		initComponents();
	}
	
	private void initComponents(){
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		this.contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(this.contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		this.lblTitel = new JLabel("Titel");
		this.lblTitel.setBounds(21, 28, 61, 16);
		contentPanel.add(this.lblTitel);
		
		this.lblArtiest = new JLabel("Artiest");
		this.lblArtiest.setBounds(21, 56, 61, 16);
		contentPanel.add(this.lblArtiest);
		
		this.lblGenre = new JLabel("Genre");
		this.lblGenre.setBounds(21, 84, 61, 16);
		contentPanel.add(this.lblGenre);
		
		this.lblBpm = new JLabel("BPM");
		this.lblBpm.setBounds(21, 112, 61, 16);
		contentPanel.add(this.lblBpm);
		
		this.txtTitel = new JTextField();
		this.txtTitel.setEditable(false);
		this.txtTitel.setHorizontalAlignment(SwingConstants.LEFT);
		this.txtTitel.setBounds(94, 22, 350, 28);
		contentPanel.add(this.txtTitel);
		this.txtTitel.setColumns(10);
		
		this.txtArtiest = new JTextField();
		this.txtArtiest.setEditable(false);
		this.txtArtiest.setHorizontalAlignment(SwingConstants.LEFT);
		this.txtArtiest.setBounds(94, 50, 350, 28);
		contentPanel.add(this.txtArtiest);
		this.txtArtiest.setColumns(10);
		
		this.txtGenre = new JTextField();
		this.txtGenre.setEditable(false);
		this.txtGenre.setHorizontalAlignment(SwingConstants.LEFT);
		this.txtGenre.setBounds(94, 78, 176, 28);
		contentPanel.add(this.txtGenre);
		this.txtGenre.setColumns(10);
		
		this.txtBpm = new JTextField();
		this.txtBpm.setEditable(false);
		this.txtBpm.setBounds(94, 106, 76, 28);
		contentPanel.add(this.txtBpm);
		this.txtBpm.setColumns(10);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("OK");
				okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						okButtonActionPerformed(e);
					}
				});
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
		}
	}
	public void toonDialoog(){
		this.setModal(true);
		this.setVisible(true);
	}

	protected void okButtonActionPerformed(ActionEvent e) {
		this.setVisible(false);
	}
}
